package com.yunyi.controller;


import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@Controller
@RequestMapping("/ai")
@RequiredArgsConstructor
public class ChatController {


    private final ChatClient chatClient;

    @GetMapping(value = "/chat")
        public Flux<String> chatWithDeepseek(String message, String chatId) {

        Flux<String> content = chatClient.prompt().user(message)
                .advisors(a -> a.param("chat_memory_conversation_id", chatId))
                .stream().content();

        return content;
    }

}
